package com.apexedu.eas.common;

import java.util.Properties;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.apexedu.eas.util.EasUtil;
import com.apexedu.framework.dao.BaseDao;

/**
 * Created with IntelliJ IDEA.
 * User: ly
 * Date: 13-11-6
 * Time: 下午4:49
 * To change this template use File | Settings | File Templates.
 */
public class BaseController {
    /**
     * 日志
     */
    protected Logger log = LoggerFactory.getLogger(this.getClass());

    /**
     * hibernate查询工具
     */
    @Resource
    protected BaseDao baseDao;

    /**
     * 系统参数
     */
    @Resource
    protected SysProperty sysProperty;
   /* @Resource
	protected com.apexedu.eas.util.DBUtil DBUtil;*/
    /**
	 * 从cas获取登录用户信息
	 */
	protected static String getUserIdFromCAS(HttpServletRequest request,String userId) {
		//读取配置文件
		Properties pro = EasUtil.getPro("extra.properties");
		String casUser = pro.getProperty("casUser");
		//从cas中 取登录的用户名 也就是学号
		if (Integer.parseInt(casUser) == 1) {
			userId = request.getRemoteUser();
		}
		return userId;
	}
}
